#pragma once
#include"Teach.h"
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
#include <algorithm>
#include "Teach.h"
#include "Stu.h"
#include "Off.h"
#include "Ren.h"
using namespace std;
namespace Project {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for ShTeachers
	/// </summary>
	public ref class ShTeachers : public System::Windows::Forms::Form
	{
		int cnt;
	public:
		ShTeachers(void)
		{
			InitializeComponent();
			fill();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~ShTeachers()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::TabControl^  tabControl1;
	protected:
	private: System::Windows::Forms::TabPage^  tabPage1;
	private: System::Windows::Forms::TabPage^  tabPage2;
	private: System::Windows::Forms::TabPage^  tabPage3;


	private: System::Windows::Forms::TabPage^  tabPage4;
	private: System::Windows::Forms::ListBox^  listBox2;
	private: System::Windows::Forms::ListBox^  listBox1;
	private: System::Windows::Forms::ListBox^  listBox3;
	private: System::Windows::Forms::ListBox^  listBox4;
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Button^  button3;
	private: System::Windows::Forms::Button^  button4;




	protected:

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(ShTeachers::typeid));
			this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
			this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->listBox2 = (gcnew System::Windows::Forms::ListBox());
			this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->listBox1 = (gcnew System::Windows::Forms::ListBox());
			this->tabPage3 = (gcnew System::Windows::Forms::TabPage());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->listBox3 = (gcnew System::Windows::Forms::ListBox());
			this->tabPage4 = (gcnew System::Windows::Forms::TabPage());
			this->button4 = (gcnew System::Windows::Forms::Button());
			this->listBox4 = (gcnew System::Windows::Forms::ListBox());
			this->tabControl1->SuspendLayout();
			this->tabPage1->SuspendLayout();
			this->tabPage2->SuspendLayout();
			this->tabPage3->SuspendLayout();
			this->tabPage4->SuspendLayout();
			this->SuspendLayout();
			// 
			// tabControl1
			// 
			this->tabControl1->Controls->Add(this->tabPage1);
			this->tabControl1->Controls->Add(this->tabPage2);
			this->tabControl1->Controls->Add(this->tabPage3);
			this->tabControl1->Controls->Add(this->tabPage4);
			this->tabControl1->Location = System::Drawing::Point(2, 4);
			this->tabControl1->Name = L"tabControl1";
			this->tabControl1->SelectedIndex = 0;
			this->tabControl1->Size = System::Drawing::Size(655, 443);
			this->tabControl1->TabIndex = 2;
			// 
			// tabPage1
			// 
			this->tabPage1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"tabPage1.BackgroundImage")));
			this->tabPage1->Controls->Add(this->button1);
			this->tabPage1->Controls->Add(this->listBox2);
			this->tabPage1->Location = System::Drawing::Point(4, 22);
			this->tabPage1->Name = L"tabPage1";
			this->tabPage1->Padding = System::Windows::Forms::Padding(3);
			this->tabPage1->Size = System::Drawing::Size(647, 417);
			this->tabPage1->TabIndex = 0;
			this->tabPage1->Text = L"Teachers";
			this->tabPage1->UseVisualStyleBackColor = true;
			this->tabPage1->Click += gcnew System::EventHandler(this, &ShTeachers::tabPage1_Click);
			// 
			// button1
			// 
			this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->button1->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->button1->Location = System::Drawing::Point(564, 370);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(80, 35);
			this->button1->TabIndex = 12;
			this->button1->Text = L"Exit";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &ShTeachers::button1_Click);
			// 
			// listBox2
			// 
			this->listBox2->BackColor = System::Drawing::Color::Silver;
			this->listBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->listBox2->ForeColor = System::Drawing::SystemColors::WindowText;
			this->listBox2->FormattingEnabled = true;
			this->listBox2->ItemHeight = 15;
			this->listBox2->Location = System::Drawing::Point(0, 0);
			this->listBox2->Name = L"listBox2";
			this->listBox2->Size = System::Drawing::Size(651, 364);
			this->listBox2->TabIndex = 0;
			// 
			// tabPage2
			// 
			this->tabPage2->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"tabPage2.BackgroundImage")));
			this->tabPage2->Controls->Add(this->button2);
			this->tabPage2->Controls->Add(this->listBox1);
			this->tabPage2->Location = System::Drawing::Point(4, 22);
			this->tabPage2->Name = L"tabPage2";
			this->tabPage2->Padding = System::Windows::Forms::Padding(3);
			this->tabPage2->Size = System::Drawing::Size(647, 417);
			this->tabPage2->TabIndex = 1;
			this->tabPage2->Text = L"Students";
			this->tabPage2->UseVisualStyleBackColor = true;
			// 
			// button2
			// 
			this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->button2->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->button2->Location = System::Drawing::Point(561, 370);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(80, 35);
			this->button2->TabIndex = 13;
			this->button2->Text = L"Exit";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &ShTeachers::button2_Click);
			// 
			// listBox1
			// 
			this->listBox1->BackColor = System::Drawing::Color::Silver;
			this->listBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->listBox1->FormattingEnabled = true;
			this->listBox1->ItemHeight = 15;
			this->listBox1->Location = System::Drawing::Point(0, 0);
			this->listBox1->Name = L"listBox1";
			this->listBox1->Size = System::Drawing::Size(651, 364);
			this->listBox1->TabIndex = 0;
			// 
			// tabPage3
			// 
			this->tabPage3->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"tabPage3.BackgroundImage")));
			this->tabPage3->Controls->Add(this->button3);
			this->tabPage3->Controls->Add(this->listBox3);
			this->tabPage3->Location = System::Drawing::Point(4, 22);
			this->tabPage3->Name = L"tabPage3";
			this->tabPage3->Padding = System::Windows::Forms::Padding(3);
			this->tabPage3->Size = System::Drawing::Size(647, 417);
			this->tabPage3->TabIndex = 2;
			this->tabPage3->Text = L"Officers";
			this->tabPage3->UseVisualStyleBackColor = true;
			this->tabPage3->Click += gcnew System::EventHandler(this, &ShTeachers::tabPage3_Click);
			// 
			// button3
			// 
			this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->button3->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->button3->Location = System::Drawing::Point(561, 370);
			this->button3->Name = L"button3";
			this->button3->Size = System::Drawing::Size(80, 35);
			this->button3->TabIndex = 13;
			this->button3->Text = L"Exit";
			this->button3->UseVisualStyleBackColor = true;
			this->button3->Click += gcnew System::EventHandler(this, &ShTeachers::button3_Click);
			// 
			// listBox3
			// 
			this->listBox3->BackColor = System::Drawing::Color::Silver;
			this->listBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->listBox3->FormattingEnabled = true;
			this->listBox3->ItemHeight = 15;
			this->listBox3->Location = System::Drawing::Point(0, 0);
			this->listBox3->Name = L"listBox3";
			this->listBox3->Size = System::Drawing::Size(651, 364);
			this->listBox3->TabIndex = 0;
			// 
			// tabPage4
			// 
			this->tabPage4->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"tabPage4.BackgroundImage")));
			this->tabPage4->Controls->Add(this->button4);
			this->tabPage4->Controls->Add(this->listBox4);
			this->tabPage4->Location = System::Drawing::Point(4, 22);
			this->tabPage4->Name = L"tabPage4";
			this->tabPage4->Padding = System::Windows::Forms::Padding(3);
			this->tabPage4->Size = System::Drawing::Size(647, 417);
			this->tabPage4->TabIndex = 3;
			this->tabPage4->Text = L"Renowned Students";
			this->tabPage4->UseVisualStyleBackColor = true;
			// 
			// button4
			// 
			this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->button4->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->button4->Location = System::Drawing::Point(561, 370);
			this->button4->Name = L"button4";
			this->button4->Size = System::Drawing::Size(80, 35);
			this->button4->TabIndex = 13;
			this->button4->Text = L"Exit";
			this->button4->UseVisualStyleBackColor = true;
			this->button4->Click += gcnew System::EventHandler(this, &ShTeachers::button4_Click);
			// 
			// listBox4
			// 
			this->listBox4->BackColor = System::Drawing::Color::Silver;
			this->listBox4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->listBox4->FormattingEnabled = true;
			this->listBox4->ItemHeight = 15;
			this->listBox4->Location = System::Drawing::Point(0, 0);
			this->listBox4->Name = L"listBox4";
			this->listBox4->Size = System::Drawing::Size(651, 364);
			this->listBox4->TabIndex = 0;
			// 
			// ShTeachers
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"$this.BackgroundImage")));
			this->ClientSize = System::Drawing::Size(659, 446);
			this->Controls->Add(this->tabControl1);
			this->Name = L"ShTeachers";
			this->Text = L"Information";
			this->tabControl1->ResumeLayout(false);
			this->tabPage1->ResumeLayout(false);
			this->tabPage2->ResumeLayout(false);
			this->tabPage3->ResumeLayout(false);
			this->tabPage4->ResumeLayout(false);
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void listView1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {

	}
	private: System::Void tabPage3_Click(System::Object^  sender, System::EventArgs^  e) {
				 
	}
	private: System::Void tabPage1_Click(System::Object^  sender, System::EventArgs^  e) {
	
	}
	private: System::Void listView2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {

	}
	private: System::Void listView4_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
	
	}
	private: void fill()
	{
				Teach t[100];
				ifstream file("TeachInfo.txt");
				cnt = 0;
				msclr::interop::marshal_context context;
				while (file >> t[cnt].name){
					t[cnt].name = gap(t[cnt].name);
					String^  i1 = context.marshal_as<String^>(t[cnt].name);
					file >> t[cnt].id;
					t[cnt].id = gap(t[cnt].id);
					String^  i2 = context.marshal_as<String^>(t[cnt].id);
					file >> t[cnt].age;
					t[cnt].age = gap(t[cnt].age);
					String^  i3 = context.marshal_as<String^>(t[cnt].age);
					file >> t[cnt].office_no;
					t[cnt].office_no = gap(t[cnt].office_no);
					String^  i4 = context.marshal_as<String^>(t[cnt].office_no);
					file >> t[cnt].qualification;
					t[cnt].qualification = gap(t[cnt].qualification);
					String^  i5 = context.marshal_as<String^>(t[cnt].qualification);
					file >> t[cnt].salary;
					t[cnt].salary = gap(t[cnt].salary);
					String^  i6 = context.marshal_as<String^>(t[cnt].salary);
					file >> t[cnt].address;
					String^  i7 = context.marshal_as<String^>(t[cnt].address);
					listBox2->Items->Add(i1 + "|" + i2 + "|" + i3 + "|" + i4 + "|" + i5 + "|" + i6 + "|" + i7);
					cnt++;
				}
				file.close();

				Stu s[100];
				ifstream file1("StuInfo.txt");
				cnt = 0;
				while (file1 >> s[cnt].name){
					s[cnt].name = gap(s[cnt].name);
					String^  i1 = context.marshal_as<String^>(s[cnt].name);
					file1 >> s[cnt].roll;
					s[cnt].roll = gap(s[cnt].roll);
					String^  i2 = context.marshal_as<String^>(s[cnt].roll);
					file1 >> s[cnt].age;
					s[cnt].age = gap(s[cnt].age);
					String^  i3 = context.marshal_as<String^>(s[cnt].age);
					file1 >> s[cnt].clas;
					s[cnt].clas = gap(s[cnt].clas);
					String^  i4 = context.marshal_as<String^>(s[cnt].clas);
					file1 >> s[cnt].fathers_name;
					s[cnt].fathers_name = gap(s[cnt].fathers_name);
					String^  i5 = context.marshal_as<String^>(s[cnt].fathers_name);
					file1 >> s[cnt].mothers_name;
					s[cnt].mothers_name = gap(s[cnt].mothers_name);
					String^  i6 = context.marshal_as<String^>(s[cnt].mothers_name);
					file1 >> s[cnt].address;
					String^  i7 = context.marshal_as<String^>(s[cnt].address);
					listBox1->Items->Add(i1 + "|" + i2 + "|" + i3 + "|" + i4 + "|" + i5 + "|" + i6 + "|" + i7);
					cnt++;
				}
				file1.close();

				Off o[100];
				ifstream file2("OffInfo.txt");
				cnt = 0;
				while (file2 >> o[cnt].name){
					o[cnt].name = gap(o[cnt].name);
					String^  i1 = context.marshal_as<String^>(o[cnt].name);
					file2 >> o[cnt].id;
					o[cnt].id = gap(o[cnt].id);
					String^  i2 = context.marshal_as<String^>(o[cnt].id);
					file2 >> o[cnt].age;
					o[cnt].age = gap(o[cnt].age);
					String^  i3 = context.marshal_as<String^>(o[cnt].age);
					file2 >> o[cnt].office_no;
					o[cnt].office_no = gap(o[cnt].office_no);
					String^  i4 = context.marshal_as<String^>(o[cnt].office_no);
					file2 >> o[cnt].qualification;
					o[cnt].qualification = gap(o[cnt].qualification);
					String^  i5 = context.marshal_as<String^>(o[cnt].qualification);
					file2 >> o[cnt].salary;
					o[cnt].salary = gap(o[cnt].salary);
					String^  i6 = context.marshal_as<String^>(o[cnt].salary);
					file2 >> o[cnt].address;
					String^  i7 = context.marshal_as<String^>(o[cnt].address);
					listBox3->Items->Add(i1 + "|" + i2 + "|" + i3 + "|" + i4 + "|" + i5 + "|" + i6 + "|" + i7);
					cnt++;
				}
				file2.close();

				Ren r[100];
				ifstream file3("ren.txt");
				cnt = 0;
				while (file3 >> r[cnt].name){
					r[cnt].name = gap(r[cnt].name);
					String ^ u1 = context.marshal_as<String ^>(r[cnt].name);
					file3 >> r[cnt].batch;
					r[cnt].batch = gap(r[cnt].batch);
					String^  u2 = context.marshal_as<String ^>(r[cnt].batch);
					file3 >> r[cnt].occupation;
					r[cnt].occupation = gap(r[cnt].occupation);
					String^  u3 = context.marshal_as<String ^>(r[cnt].occupation);
					file3 >> r[cnt].achievement;
					String^  u4 = context.marshal_as<String ^>(r[cnt].achievement);
					listBox3->Items->Add(u1 + "|" + u2 + "|" + u3 + "|" + u4 );
					cnt++;
				}
				file3.close();
	}
	
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
}
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
}
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
}
		 private:string gap(string s)
		 {
				int j = 20;
				while (s.size() <= j){
					s += " ";
				}
				return s;
		 }
};
}